package com.wego.pdcms.module.main.dal.mysql.patient;

import java.util.*;

import com.wego.pdcms.framework.common.pojo.PageResult;
import com.wego.pdcms.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.wego.pdcms.framework.mybatis.core.mapper.BaseMapperX;
import com.wego.pdcms.module.main.dal.dataobject.patient.PatientDO;
import org.apache.ibatis.annotations.Mapper;
import com.wego.pdcms.module.main.controller.admin.patient.vo.*;

/**
 * 患者信息 Mapper
 *
 * @author gjp
 */
@Mapper
public interface PatientMapper extends BaseMapperX<PatientDO> {

    default PageResult<PatientDO> selectPage(PatientPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PatientDO>()
                .eqIfPresent(PatientDO::getPatientHisId, reqVO.getPatientHisId())
                .eqIfPresent(PatientDO::getOutpatientServiceNumber, reqVO.getOutpatientServiceNumber())
                .eqIfPresent(PatientDO::getPdNumber, reqVO.getPdNumber())
                .eqIfPresent(PatientDO::getPatientNm, reqVO.getPatientNm())
                .eqIfPresent(PatientDO::getPatientPy, reqVO.getPatientPy())
                .eqIfPresent(PatientDO::getPatientSex, reqVO.getPatientSex())
                .eqIfPresent(PatientDO::getPatientAge, reqVO.getPatientAge())
                .eqIfPresent(PatientDO::getPatientNation, reqVO.getPatientNation())
                .eqIfPresent(PatientDO::getMaritalStatus, reqVO.getMaritalStatus())
                .eqIfPresent(PatientDO::getPatientCardId, reqVO.getPatientCardId())
                .eqIfPresent(PatientDO::getChargeMode, reqVO.getChargeMode())
                .eqIfPresent(PatientDO::getChargeType, reqVO.getChargeType())
                .eqIfPresent(PatientDO::getPatientBirthday, reqVO.getPatientBirthday())
                .eqIfPresent(PatientDO::getPatientHeight, reqVO.getPatientHeight())
                .eqIfPresent(PatientDO::getDryWeight, reqVO.getDryWeight())
                .betweenIfPresent(PatientDO::getInHospitalDate, reqVO.getInHospitalDate())
                .betweenIfPresent(PatientDO::getDischargeDate, reqVO.getDischargeDate())
                .betweenIfPresent(PatientDO::getDeathDate, reqVO.getDeathDate())
                .eqIfPresent(PatientDO::getPatientTel, reqVO.getPatientTel())
                .eqIfPresent(PatientDO::getPatientTel2, reqVO.getPatientTel2())
                .eqIfPresent(PatientDO::getPostCode, reqVO.getPostCode())
                .eqIfPresent(PatientDO::getHospitalizationNumber, reqVO.getHospitalizationNumber())
                .eqIfPresent(PatientDO::getPatientAddress, reqVO.getPatientAddress())
                .eqIfPresent(PatientDO::getPatientWorkType, reqVO.getPatientWorkType())
                .eqIfPresent(PatientDO::getPatientUnit, reqVO.getPatientUnit())
                .eqIfPresent(PatientDO::getEmergencyContact, reqVO.getEmergencyContact())
                .eqIfPresent(PatientDO::getPatientRelation, reqVO.getPatientRelation())
                .eqIfPresent(PatientDO::getYiBaoCard, reqVO.getYiBaoCard())
                .eqIfPresent(PatientDO::getIsActive, reqVO.getIsActive())
                .eqIfPresent(PatientDO::getCreateBy, reqVO.getCreateBy())
                .eqIfPresent(PatientDO::getCreateDt, reqVO.getCreateDt())
                .eqIfPresent(PatientDO::getUpdateBy, reqVO.getUpdateBy())
                .eqIfPresent(PatientDO::getUpdateDt, reqVO.getUpdateDt())
                .eqIfPresent(PatientDO::getPatientTypeOne, reqVO.getPatientTypeOne())
                .eqIfPresent(PatientDO::getPatientTypeTwo, reqVO.getPatientTypeTwo())
                .eqIfPresent(PatientDO::getDiagnose, reqVO.getDiagnose())
                .eqIfPresent(PatientDO::getProtopathy, reqVO.getProtopathy())
                .eqIfPresent(PatientDO::getPathologicDiagnose, reqVO.getPathologicDiagnose())
                .eqIfPresent(PatientDO::getComplication, reqVO.getComplication())
                .eqIfPresent(PatientDO::getZhiguanType, reqVO.getZhiguanType())
                .betweenIfPresent(PatientDO::getZhiguanDate, reqVO.getZhiguanDate())
                .eqIfPresent(PatientDO::getPastMedicalHistory, reqVO.getPastMedicalHistory())
                .eqIfPresent(PatientDO::getHdYears, reqVO.getHdYears())
                .eqIfPresent(PatientDO::getRtYears, reqVO.getRtYears())
                .eqIfPresent(PatientDO::getIsHepatitisB, reqVO.getIsHepatitisB())
                .eqIfPresent(PatientDO::getIsHepatitisC, reqVO.getIsHepatitisC())
                .eqIfPresent(PatientDO::getIsDm, reqVO.getIsDm())
                .eqIfPresent(PatientDO::getUrinaryVolume, reqVO.getUrinaryVolume())
                .eqIfPresent(PatientDO::getIsHiv, reqVO.getIsHiv())
                .eqIfPresent(PatientDO::getIsSyphilis, reqVO.getIsSyphilis())
                .eqIfPresent(PatientDO::getPatientStatus, reqVO.getPatientStatus())
                .betweenIfPresent(PatientDO::getFirstTreatmentDate, reqVO.getFirstTreatmentDate())
                .eqIfPresent(PatientDO::getRemarks, reqVO.getRemarks())
                .eqIfPresent(PatientDO::getLeavePdReason, reqVO.getLeavePdReason())
                .betweenIfPresent(PatientDO::getLeavePdDate, reqVO.getLeavePdDate())
                .eqIfPresent(PatientDO::getIsPeritonitisPatient, reqVO.getIsPeritonitisPatient())
                .eqIfPresent(PatientDO::getIsExternalInfectionPatient, reqVO.getIsExternalInfectionPatient())
                .eqIfPresent(PatientDO::getIsCapcontrolPatient, reqVO.getIsCapcontrolPatient())
                .eqIfPresent(PatientDO::getFirstPdTimes, reqVO.getFirstPdTimes())
                .eqIfPresent(PatientDO::getPdTimes, reqVO.getPdTimes())
                .eqIfPresent(PatientDO::getRevisitCycle, reqVO.getRevisitCycle())
                .betweenIfPresent(PatientDO::getRevisitDate, reqVO.getRevisitDate())
                .eqIfPresent(PatientDO::getRevisitRecordsId, reqVO.getRevisitRecordsId())
                .eqIfPresent(PatientDO::getFollowupCycle, reqVO.getFollowupCycle())
                .betweenIfPresent(PatientDO::getNextFollowupDate, reqVO.getNextFollowupDate())
                .eqIfPresent(PatientDO::getPatientFlag, reqVO.getPatientFlag())
                .eqIfPresent(PatientDO::getDeathReason, reqVO.getDeathReason())
                .eqIfPresent(PatientDO::getLinchuangZhenduan, reqVO.getLinchuangZhenduan())
                .eqIfPresent(PatientDO::getHemodialysisReason, reqVO.getHemodialysisReason())
                .eqIfPresent(PatientDO::getEducationLevel, reqVO.getEducationLevel())
                .eqIfPresent(PatientDO::getOccupation, reqVO.getOccupation())
                .betweenIfPresent(PatientDO::getProtopathyDate, reqVO.getProtopathyDate())
                .betweenIfPresent(PatientDO::getClinicalDiagnosisDate, reqVO.getClinicalDiagnosisDate())
                .eqIfPresent(PatientDO::getIsInOutExportStatus, reqVO.getIsInOutExportStatus())
                .eqIfPresent(PatientDO::getPatientProperty, reqVO.getPatientProperty())
                .eqIfPresent(PatientDO::getRegistrationCode, reqVO.getRegistrationCode())
                .eqIfPresent(PatientDO::getQrCodeImg, reqVO.getQrCodeImg())
                .eqIfPresent(PatientDO::getChargeNurse, reqVO.getChargeNurse())
                .eqIfPresent(PatientDO::getChargeDoctor, reqVO.getChargeDoctor())
                .eqIfPresent(PatientDO::getHospitalTimes, reqVO.getHospitalTimes())
                .eqIfPresent(PatientDO::getHospitalDepart, reqVO.getHospitalDepart())
                .eqIfPresent(PatientDO::getHospitalBed, reqVO.getHospitalBed())
                .eqIfPresent(PatientDO::getChargeDoctorDepart, reqVO.getChargeDoctorDepart())
                .eqIfPresent(PatientDO::getHospitalDepartNumber, reqVO.getHospitalDepartNumber())
                .betweenIfPresent(PatientDO::getCaseTypeDate, reqVO.getCaseTypeDate())
                .eqIfPresent(PatientDO::getCaseTypeResult, reqVO.getCaseTypeResult())
                .eqIfPresent(PatientDO::getIsRegister, reqVO.getIsRegister())
                .betweenIfPresent(PatientDO::getNextVasDate, reqVO.getNextVasDate())
                .betweenIfPresent(PatientDO::getNextKtvDate, reqVO.getNextKtvDate())
                .betweenIfPresent(PatientDO::getNextPetDate, reqVO.getNextPetDate())
                .betweenIfPresent(PatientDO::getInDate, reqVO.getInDate())
                .eqIfPresent(PatientDO::getLostFollowReason, reqVO.getLostFollowReason())
                .orderByDesc(PatientDO::getPatientId));
    }

    default List<PatientDO> selectList(PatientExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<PatientDO>()
                .eqIfPresent(PatientDO::getPatientHisId, reqVO.getPatientHisId())
                .eqIfPresent(PatientDO::getOutpatientServiceNumber, reqVO.getOutpatientServiceNumber())
                .eqIfPresent(PatientDO::getPdNumber, reqVO.getPdNumber())
                .eqIfPresent(PatientDO::getPatientNm, reqVO.getPatientNm())
                .eqIfPresent(PatientDO::getPatientPy, reqVO.getPatientPy())
                .eqIfPresent(PatientDO::getPatientSex, reqVO.getPatientSex())
                .eqIfPresent(PatientDO::getPatientAge, reqVO.getPatientAge())
                .eqIfPresent(PatientDO::getPatientNation, reqVO.getPatientNation())
                .eqIfPresent(PatientDO::getMaritalStatus, reqVO.getMaritalStatus())
                .eqIfPresent(PatientDO::getPatientCardId, reqVO.getPatientCardId())
                .eqIfPresent(PatientDO::getChargeMode, reqVO.getChargeMode())
                .eqIfPresent(PatientDO::getChargeType, reqVO.getChargeType())
                .eqIfPresent(PatientDO::getPatientBirthday, reqVO.getPatientBirthday())
                .eqIfPresent(PatientDO::getPatientHeight, reqVO.getPatientHeight())
                .eqIfPresent(PatientDO::getDryWeight, reqVO.getDryWeight())
                .betweenIfPresent(PatientDO::getInHospitalDate, reqVO.getInHospitalDate())
                .betweenIfPresent(PatientDO::getDischargeDate, reqVO.getDischargeDate())
                .betweenIfPresent(PatientDO::getDeathDate, reqVO.getDeathDate())
                .eqIfPresent(PatientDO::getPatientTel, reqVO.getPatientTel())
                .eqIfPresent(PatientDO::getPatientTel2, reqVO.getPatientTel2())
                .eqIfPresent(PatientDO::getPostCode, reqVO.getPostCode())
                .eqIfPresent(PatientDO::getHospitalizationNumber, reqVO.getHospitalizationNumber())
                .eqIfPresent(PatientDO::getPatientAddress, reqVO.getPatientAddress())
                .eqIfPresent(PatientDO::getPatientWorkType, reqVO.getPatientWorkType())
                .eqIfPresent(PatientDO::getPatientUnit, reqVO.getPatientUnit())
                .eqIfPresent(PatientDO::getEmergencyContact, reqVO.getEmergencyContact())
                .eqIfPresent(PatientDO::getPatientRelation, reqVO.getPatientRelation())
                .eqIfPresent(PatientDO::getYiBaoCard, reqVO.getYiBaoCard())
                .eqIfPresent(PatientDO::getIsActive, reqVO.getIsActive())
                .eqIfPresent(PatientDO::getCreateBy, reqVO.getCreateBy())
                .eqIfPresent(PatientDO::getCreateDt, reqVO.getCreateDt())
                .eqIfPresent(PatientDO::getUpdateBy, reqVO.getUpdateBy())
                .eqIfPresent(PatientDO::getUpdateDt, reqVO.getUpdateDt())
                .eqIfPresent(PatientDO::getPatientTypeOne, reqVO.getPatientTypeOne())
                .eqIfPresent(PatientDO::getPatientTypeTwo, reqVO.getPatientTypeTwo())
                .eqIfPresent(PatientDO::getDiagnose, reqVO.getDiagnose())
                .eqIfPresent(PatientDO::getProtopathy, reqVO.getProtopathy())
                .eqIfPresent(PatientDO::getPathologicDiagnose, reqVO.getPathologicDiagnose())
                .eqIfPresent(PatientDO::getComplication, reqVO.getComplication())
                .eqIfPresent(PatientDO::getZhiguanType, reqVO.getZhiguanType())
                .betweenIfPresent(PatientDO::getZhiguanDate, reqVO.getZhiguanDate())
                .eqIfPresent(PatientDO::getPastMedicalHistory, reqVO.getPastMedicalHistory())
                .eqIfPresent(PatientDO::getHdYears, reqVO.getHdYears())
                .eqIfPresent(PatientDO::getRtYears, reqVO.getRtYears())
                .eqIfPresent(PatientDO::getIsHepatitisB, reqVO.getIsHepatitisB())
                .eqIfPresent(PatientDO::getIsHepatitisC, reqVO.getIsHepatitisC())
                .eqIfPresent(PatientDO::getIsDm, reqVO.getIsDm())
                .eqIfPresent(PatientDO::getUrinaryVolume, reqVO.getUrinaryVolume())
                .eqIfPresent(PatientDO::getIsHiv, reqVO.getIsHiv())
                .eqIfPresent(PatientDO::getIsSyphilis, reqVO.getIsSyphilis())
                .eqIfPresent(PatientDO::getPatientStatus, reqVO.getPatientStatus())
                .betweenIfPresent(PatientDO::getFirstTreatmentDate, reqVO.getFirstTreatmentDate())
                .eqIfPresent(PatientDO::getRemarks, reqVO.getRemarks())
                .eqIfPresent(PatientDO::getLeavePdReason, reqVO.getLeavePdReason())
                .betweenIfPresent(PatientDO::getLeavePdDate, reqVO.getLeavePdDate())
                .eqIfPresent(PatientDO::getIsPeritonitisPatient, reqVO.getIsPeritonitisPatient())
                .eqIfPresent(PatientDO::getIsExternalInfectionPatient, reqVO.getIsExternalInfectionPatient())
                .eqIfPresent(PatientDO::getIsCapcontrolPatient, reqVO.getIsCapcontrolPatient())
                .eqIfPresent(PatientDO::getFirstPdTimes, reqVO.getFirstPdTimes())
                .eqIfPresent(PatientDO::getPdTimes, reqVO.getPdTimes())
                .eqIfPresent(PatientDO::getRevisitCycle, reqVO.getRevisitCycle())
                .betweenIfPresent(PatientDO::getRevisitDate, reqVO.getRevisitDate())
                .eqIfPresent(PatientDO::getRevisitRecordsId, reqVO.getRevisitRecordsId())
                .eqIfPresent(PatientDO::getFollowupCycle, reqVO.getFollowupCycle())
                .betweenIfPresent(PatientDO::getNextFollowupDate, reqVO.getNextFollowupDate())
                .eqIfPresent(PatientDO::getPatientFlag, reqVO.getPatientFlag())
                .eqIfPresent(PatientDO::getDeathReason, reqVO.getDeathReason())
                .eqIfPresent(PatientDO::getLinchuangZhenduan, reqVO.getLinchuangZhenduan())
                .eqIfPresent(PatientDO::getHemodialysisReason, reqVO.getHemodialysisReason())
                .eqIfPresent(PatientDO::getEducationLevel, reqVO.getEducationLevel())
                .eqIfPresent(PatientDO::getOccupation, reqVO.getOccupation())
                .betweenIfPresent(PatientDO::getProtopathyDate, reqVO.getProtopathyDate())
                .betweenIfPresent(PatientDO::getClinicalDiagnosisDate, reqVO.getClinicalDiagnosisDate())
                .eqIfPresent(PatientDO::getIsInOutExportStatus, reqVO.getIsInOutExportStatus())
                .eqIfPresent(PatientDO::getPatientProperty, reqVO.getPatientProperty())
                .eqIfPresent(PatientDO::getRegistrationCode, reqVO.getRegistrationCode())
                .eqIfPresent(PatientDO::getQrCodeImg, reqVO.getQrCodeImg())
                .eqIfPresent(PatientDO::getChargeNurse, reqVO.getChargeNurse())
                .eqIfPresent(PatientDO::getChargeDoctor, reqVO.getChargeDoctor())
                .eqIfPresent(PatientDO::getHospitalTimes, reqVO.getHospitalTimes())
                .eqIfPresent(PatientDO::getHospitalDepart, reqVO.getHospitalDepart())
                .eqIfPresent(PatientDO::getHospitalBed, reqVO.getHospitalBed())
                .eqIfPresent(PatientDO::getChargeDoctorDepart, reqVO.getChargeDoctorDepart())
                .eqIfPresent(PatientDO::getHospitalDepartNumber, reqVO.getHospitalDepartNumber())
                .betweenIfPresent(PatientDO::getCaseTypeDate, reqVO.getCaseTypeDate())
                .eqIfPresent(PatientDO::getCaseTypeResult, reqVO.getCaseTypeResult())
                .eqIfPresent(PatientDO::getIsRegister, reqVO.getIsRegister())
                .betweenIfPresent(PatientDO::getNextVasDate, reqVO.getNextVasDate())
                .betweenIfPresent(PatientDO::getNextKtvDate, reqVO.getNextKtvDate())
                .betweenIfPresent(PatientDO::getNextPetDate, reqVO.getNextPetDate())
                .betweenIfPresent(PatientDO::getInDate, reqVO.getInDate())
                .eqIfPresent(PatientDO::getLostFollowReason, reqVO.getLostFollowReason())
                .orderByDesc(PatientDO::getPatientId));
    }

}
